import 'package:flutter/material.dart';
import 'package:power_house/pages/home/info/data.dart';
import 'package:power_house/widgets/common_image.dart';

var textStyle = const TextStyle(color: Colors.black54);

class ItemWidget extends StatelessWidget {
  final InfoItem data;

  const ItemWidget(
    this.data, {
    Key? key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () {
        Navigator.of(context).pushNamed(data.navigateUri);
      },
      child: Container(
        height: 100.0, //不设置高度mainAxisAlignment: MainAxisAlignment.spaceBetween没有UI效果
        padding: const EdgeInsets.only(left: 10.0, right: 10.0, bottom: 10.0),
        child: Row(
          children: [
            CommonImage(
              data.imageUri,
              width: 120.0,
              height: 90.0,
            ),
            const Padding(padding: EdgeInsets.only(left: 10)),
            Expanded(
                child: Column(mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [
              Text(
                data.title,
                textAlign: TextAlign.start,
                style: const TextStyle(fontWeight: FontWeight.w600, color: Colors.black, fontSize: 16.0),
              ),
              Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
                Text(
                  data.source,
                  style: textStyle,
                ),
                Text(
                  data.time,
                  style: textStyle,
                )
              ])
            ]))
          ],
        ),
      ),
    );
  }
}
